package zuoye3;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class SeverTest {
    public static void main(String[] args) {
        ServerSocket serverSocket=null;
        Socket socket=null;
        InputStream is=null;
        ObjectInputStream ois=null;
        OutputStream os=null;
        try {
            serverSocket=new ServerSocket(5000);
            socket=serverSocket.accept();
            is=socket.getInputStream();
            ois=new ObjectInputStream(is);
            User user=(User) ois.readObject();
            os=socket.getOutputStream();
            if (!user.getUserName().equals("bjsxt") || !user.getPassword().equals("bjsxt")) {
                String replay1="登录失败！";
                os.write(replay1.getBytes());
            }
            if (user.getUserName().equals("bjsxt") || user.getPassword().equals("bjsxt")) {
                String replay2="登录成功！";
                os.write(replay2.getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
